package com.jxt.myjxtmanager.ui.presenter;

import android.content.Context;

import com.jxt.myjxtmanager.entity.FeedbackBean;
import com.jxt.myjxtmanager.okHttp.Result;
import com.jxt.myjxtmanager.ui.inter.FeedbackInter;
import com.jxt.myjxtmanager.ui.inter.OnGenericResultListener;
import com.jxt.myjxtmanager.ui.model.FeedbackModel;
import com.jxt.myjxtmanager.views.CustomProgressDialog;


/**
 * Created by Administrator on 2017/2/16 0016.
 */
public class FeedbackPresenter implements OnGenericResultListener<Result> {
    private final CustomProgressDialog dialog;
    private Context context;
    private FeedbackModel model;
    private FeedbackInter inter;
    public FeedbackPresenter(Context context, FeedbackInter inter){
        this.context=context;
        this.inter=inter;
        model=new FeedbackModel(context);
        dialog = new CustomProgressDialog(context, "");
    }
    public void dismissDialog() {
        if (dialog != null) {
            dialog.dismiss();
        }
    }
    /**
     * 意见返回的请求
     */
    public  void getFeedback(long user_id,FeedbackBean feedback){
        if (dialog != null) {
            dialog.showDialog();
        }
        model.httpFeekback(context,user_id,feedback,this);
    }

    @Override
    public void onSuccess(Result resultBeans) {
        inter.resuleCarSuccess(resultBeans);
    }

    @Override
    public void onSuccess02(Result resultBeans) {

    }

    @Override
    public void onFailure(int code, String msg) {
        if (code == 2) {
            inter.showToast(msg);
        }
    }
}
